package cn.progen.model;




import cn.progen.constant.FiledsTypeTable;
import cn.progen.util.StringUtil;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class Fileds implements Serializable {
	private String name;
	private String mysqlName;
	private String columnNameFirstLower;
	private String dataType;
	private Integer length;
	private String javaType;
	private String javaFullType;
	private String mysqlType;
	private String columnKey;
	private String columnComment;



	public String getColumnKey() {
		return columnKey;
	}

	public void setColumnKey(String columnKey) {
		this.columnKey = columnKey;
	}

	public String getColumnComment() {
		return columnComment;
	}

	public void setColumnComment(String columnComment) {
		this.columnComment = columnComment;
	}

	public String getMysqlName() {
		return mysqlName;
	}
	public void setMysqlName(String mysqlName) {
		this.mysqlName = mysqlName;
	}
	public String getColumnNameFirstLower() {
		return columnNameFirstLower;
	}
	public void setColumnNameFirstLower(String columnNameFirstLower) {
		this.columnNameFirstLower = columnNameFirstLower;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.setMysqlName(name);
		name= StringUtil.columnToProperty(name);
		this.name = StringUtil.firstLetterToUpper(name);
		setColumnNameFirstLower(name);
	}
	
	public Integer getLength() {
		return length;
	}
	public void setLength(Integer length) {
		this.length = length;
	}
	public String getDataType() {
		return dataType;
	}
	public void setDataType(String dataType) {		
		this.dataType = dataType;
		this.setJavaFullType(FiledsTypeTable.JAVATYPETABLE.get(dataType));
		this.setMysqlType(FiledsTypeTable.JDBCTYPETABLE.get(FiledsTypeTable.JAVATYPETABLE.get(dataType)));
		//constant.FiledsTypeTable.JAVATYPETABLE.get(dataType)
		
	}
	public String getJavaType() {
		return javaType;
	}
	public void setJavaType(String javaType) {
		this.javaType = javaType;	
	}
	public String getMysqlType() {
		return mysqlType;
	}
	public void setMysqlType(String mysqlType) {
		this.mysqlType = mysqlType;
	}
	
	
	public String getJavaFullType() {
		return javaFullType;
	}
	public void setJavaFullType(String javaFullType) {
		this.javaFullType = javaFullType;
		this.setJavaType(StringUtil.subLastToEnd(javaFullType,"."));
	}


	@Override
	public String toString() {
		return "Fileds{" +
				"name='" + name + '\'' +
				", mysqlName='" + mysqlName + '\'' +
				", columnNameFirstLower='" + columnNameFirstLower + '\'' +
				", dataType='" + dataType + '\'' +
				", length=" + length +
				", javaType='" + javaType + '\'' +
				", javaFullType='" + javaFullType + '\'' +
				", mysqlType='" + mysqlType + '\'' +
				", columnKey='" + columnKey + '\'' +
				", columnComment='" + columnComment + '\'' +
				'}';
	}
}
